package com.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.pojo.domain.Clue;
import com.crm.pojo.domain.ClueRecord;
import com.crm.pojo.dto.CluePoolDto;
import com.crm.pojo.dto.ClueDto;
import com.crm.pojo.dto.ClueFalseDto;
import com.crm.pojo.vo.ClueRecordVo;
import com.crm.pojo.vo.ClueVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ClueMapper extends BaseMapper<Clue> {


    List<ClueVo>  list(ClueDto clueDto);

    @Select("select * from clue where id = #{id}")
    ClueVo getById(Long id);

    void add(Clue clue);
    //线索跟进
    void record(Clue clue);

    @Select("select * from clue_record where clue_id = #{clueId}")
    List<ClueRecordVo> clueRecord(Long clueId);

    void addRecord(ClueRecord clueRecord);
    @Update("update clue set false_count = false_count + 1 , is_pool = 1 where id = #{clueId}")
    void falseCount(Long clueId);

    void falseReson(ClueFalseDto clueFalseDto);
    @Delete("delete from clue where id = #{clueId}")
    void myDeleteById(Long clueId);

    void assignment(CluePoolDto cluePoolDto);

    void gain(CluePoolDto cluePoolDto);

    void transfer(Long oldId, Long newId);


    @Update("update clue set finish_time = NOW() where id = #{id}")
    void endById(Long id);
}
